// pages/user/index.js
const {
  SelTabbar
} = require('../../utils/tab-bar-sel.js')
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    statusBarHeight: app.globalData.statusBarHeight,
    bararr: ["动态", "赞"],
    baridx: 0,
  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    SelTabbar(this, 3)
  },
  onReady() {
    wx.request({
      url: 'https://apiv2.xdbbtswu.com/bbtOf/api/general/get_ip_address.php',
      success: (res) => {
        console.log(res.data.res.province)
        this.setData({
          ['user_info.province']: res.data.res.province
        })
      }
    })
    wx.request({
      url: 'https://qh-free.supengjun.com/qinghang/api/user/user_details?user_id=100001',
      header: {
        token: "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiIhQCMkJSomIiwiYXVkIjoiIiwiaWF0IjoxNzAxMjM3OTI4LCJuYmYiOjE3MDEyMzc5MzEsImV4cCI6MTcwMTg0MjcyOCwiZGF0YSI6eyJ1aWQiOjEwMTA2NX19.5yLdFOiD8KV6rVNRGre35m1FJsisQOqc6k8ILQYtcAk"
      },
      success: (res) => {
        console.log(res)
        this.setData({
          user_info: res.data.data
        })
      }
    })
  },
  onPageScroll(e) {
    var trans = (e.scrollTop > 350 ? 350 : e.scrollTop) / 350;
    this.setData({
      navbarTrans: trans
    })
  },
  /**
   * 跨页面
   * @param {*} e 
   */
  ComeToPage(e) {
    const {
      url
    } = e.currentTarget.dataset
    wx.navigateTo({
      url,
    })
  }
})